﻿@model Core.Models.Post
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout_Admin2.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/ckeditor/ckeditor.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/ckeditor/adapters/jquery.js")" type="text/javascript"></script>
<div class="panel panel-success">
    <div class="panel-heading">
        <h2 class="panel-title">
            Edit Post</h2>
    </div>
    <div class="panel-body">
        @using (Html.BeginForm("Edit", "Post", FormMethod.Post, new { id = "myForm", @class = "form-horizontal", @role = "form" }))
        {
            @Html.ValidationSummary(true)
            @Html.HiddenFor(model => model.Id)
            <div class="form-group">
                <div class="col-sm-1 control-label">
                    @Html.LabelFor(model => model.Title)</div>
                <div class="col-sm-11">
                    @Html.ValidationMessageFor(model => model.Title)
                    @Html.TextBoxFor(model => model.Title, new { @class = "form-control" })
                </div>
            </div>
            
            <div class="form-group">
                <div class="col-sm-1 control-label">
                    @Html.LabelFor(model => model.Content)</div>
                <div class="col-sm-11">
                    @Html.ValidationMessageFor(model => model.Content)
                    @Html.TextAreaFor(model => model.Content, new { @id = "ckeditorContent", @class = "form-control" })
                    <script type="text/javascript">
                        $(function () {
                            CKEDITOR.config.htmlEncodeOutput = true;
                            CKEDITOR.replace('ckeditorContent');
                        });

                        function CKupdate() {
                            for (instance in CKEDITOR.instances)
                                CKEDITOR.instances[instance].updateElement();
                        }
                    </script>
                </div>
            </div>
            
            <div class="form-group">
                <div class="col-sm-1 control-label">
                </div>
                <div class="col-sm-7">
                    <input class="btn btn-success" type="submit" onclick="CKupdate();" value="Save" />
                </div>
            </div>
        }
    </div>
</div>
